﻿using System;
#if ODATALIB_ASYNC
using System.Threading.Tasks; 
#endif
namespace Microsoft.Data.OData
{
    /// <summary> Base class for OData parameter readers. </summary>
    public abstract class ODataParameterReader
    {
        /// <summary> Gets the current state of the reader. </summary>
        /// <returns> The current state of the reader. </returns>
        public abstract ODataParameterReaderState State
        {
            get;
        }
        /// <summary> Gets the name of the current parameter that is being read. </summary>
        /// <returns> The name of the current parameter that is being read. </returns>
        public abstract string Name
        {
            get;
        }
        /// <summary> Gets the value of the current parameter that is being read. </summary>
        /// <returns> The value of the current parameter that is being read. </returns>
        /// <remarks>
        /// This property returns a primitive value, an ODataComplexValue or null when State is ODataParameterReaderState.Value.
        /// This property returns null when State is ODataParameterReaderState.Entry, ODataParameterReaderState.Feed or ODataParameterReaderState.Collection.
        /// </remarks>
        public abstract object Value
        {
            get;
        }
        /// <summary> Creates an <see cref="T:Microsoft.Data.OData.ODataCollectionReader" /> to read the collection value when the state is ODataParameterReaderState.Collection. </summary>
        /// <returns>An <see cref="T:Microsoft.Data.OData.ODataCollectionReader" /> to read the collection value when the state is ODataParameterReaderState.Collection.</returns>
        /// <remarks>
        /// When the state is ODataParameterReaderState.Collection, the Name property of the <see cref="T:Microsoft.Data.OData.ODataParameterReader" /> returns the name of the parameter
        /// and the Value property of the <see cref="T:Microsoft.Data.OData.ODataParameterReader" /> returns null. Calling this method in any other state will cause an ODataException to be thrown.
        /// </remarks>
        public abstract ODataCollectionReader CreateCollectionReader();
        /// <summary> Reads the next parameter from the message payload. </summary>
        /// <returns>true if more items were read; otherwise false.</returns>
        public abstract bool Read();
#if ODATALIB_ASYNC
        /// <summary> Asynchronously reads the next item from the message payload. </summary>
        /// <returns>A task that when completed indicates whether more items were read.</returns>
        public abstract Task<bool> ReadAsync(); 
#endif
    }
}
